<?php
	$hostName = "localhost";
	$username = "root";
	$password = "";
	$databaseName = "NTSon01_Nhom04";
?>
<?php
	function showError()
	{
		die("Error " . mysql_errno( ). " : " . mysql_error( ));
	}
?>
<?php

	$maso = $_REQUEST["MaSo"];
	$tensanpham = $_REQUEST["TenSanPham"];
	$soluong = $_REQUEST["SoLuong"];
	$tinhtrangdang = $_REQUEST["TinhTrangDang"];
	$tinhtrangxoa = $_REQUEST["TinhTrangXoa"];
	$giasanpham = $_REQUEST["GiaSanPham"];
	
	$cnn = mysql_connect( $hostName, $username, $password );
	if ( ! $cnn )
		showError();
             
    $dbselect = mysql_select_db( $databaseName);
    if(!$dbselect)
        showError();
	
	mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'", $cnn);
	
	//$query = "UPDATE san_pham SET TenSanPham=123, SoLuong=123, TinhTrangDang=0, TinhTrangXoa=5, GiaSanPham=1 WHERE MaSo=24";			
	//$table = "san_pham";
	$query = "UPDATE  san_pham SET TenSanPham=N'$tensanpham', SoLuong=$soluong, TinhTrangDang=$tinhtrangdang, TinhTrangXoa=$tinhtrangxoa, GiaSanPham=$giasanpham WHERE MaSo=$maso";
	//$query = "UPDATE  $table SET hoten='$hoten', diachi='$diachi' WHERE mahs='$mahs'";
	$result = mysql_query($query, $cnn);
	
	if (mysql_affected_rows())
	{
		echo "1";
	}
	else
	{
		echo "0";
	}

	
?>